From: Jo-Philipp Wich Date: Tue, 30 Mar 2021 13:10:00 +0000 (+0200) Subject: treewide: remove ucode module preloading X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22http:/www.crowdsec.net/%22/%22https:/collectd.org/%22http:/www.crowdsec.net/%22?a=commitdiff_plain;h=25287af31cf7a4f9b64a1e0e32b5ec2f4cb28b77;p=project%2Ffirewall4.git treewide: remove ucode module preloading Instead of preloading ucode modules via the cmdline, require the modules as needed. This simplifies test case constructions since mock modules can be injected by modifying the search path. Signed-off-by: Jo-Philipp Wich --- diff --git a/root/usr/sbin/fw4 b/root/usr/sbin/fw4 index ac95473..3e7388b 100755 --- a/root/usr/sbin/fw4 +++ b/root/usr/sbin/fw4 @@ -31,13 +31,13 @@ start() { esac ACTION=start \ - ucode -S -m fs -m uci -m ubus -m fw4 -i $MAIN | nft $VERBOSE -f /proc/self/fd/0 + ucode -S -i $MAIN | nft $VERBOSE -f /proc/self/fd/0 } 1000>$LOCK } print() { ACTION=print \ - ucode -S -m fs -m uci -m ubus -m fw4 -i $MAIN + ucode -S -i $MAIN } stop() { @@ -68,12 +68,12 @@ flush() { reload_sets() { ACTION=reload-sets \ - flock -x $LOCK ucode -S -m fs -m uci -m ubus -m fw4 -i $MAIN | nft $VERBOSE -f /proc/self/fd/0 + flock -x $LOCK ucode -S -i $MAIN | nft $VERBOSE -f /proc/self/fd/0 } lookup() { ACTION=$1 OBJECT=$2 DEVICE=$3 \ - flock -x $LOCK ucode -S -m fs -m uci -m ubus -m fw4 -i $MAIN + flock -x $LOCK ucode -S -i $MAIN } while [ -n "$1" ]; do diff --git a/root/usr/share/firewall4/main.uc b/root/usr/share/firewall4/main.uc index d71e876..6012bd1 100644 --- a/root/usr/share/firewall4/main.uc +++ b/root/usr/share/firewall4/main.uc @@ -1,5 +1,7 @@ {% +let fw4 = require("fw4"); + /* Find existing sets. * * Unfortunately, terse mode (-t) is incompatible with JSON output so diff --git a/root/usr/share/ucode/fw4.uc b/root/usr/share/ucode/fw4.uc index 1d98f61..25df7a6 100644 --- a/root/usr/share/ucode/fw4.uc +++ b/root/usr/share/ucode/fw4.uc @@ -1,5 +1,9 @@ {% +let fs = require("fs"); +let uci = require("uci"); +let ubus = require("ubus"); + let STATEFILE = "/var/run/fw4.state"; let PARSE_LIST = 0x01;